using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Linq;
using Seer.SeerSocket;


[ApiController]
[Route("[controller]/[action]")]
public class UserController : ControllerBase
{

    private readonly ILogger<UserController> logger;
    private readonly SqliteDbContext dbContext;

	private readonly IDistributedCacheHelper helper;

	private readonly SeerSocket seerSocket;

    public UserController(ILogger<UserController> logger, SqliteDbContext dbContext,IDistributedCacheHelper helper,SeerSocket seerSocket)
    {
        this.logger = logger;
        this.dbContext = dbContext;
        this.helper = helper;
        this.seerSocket = seerSocket;
    }


    [HttpGet]
    public async Task<string> Get()
    {
		return await helper.GetOrCreateAsync<string>("all1", async e => this.seerSocket.Send(0x044c),3);
    }

    [HttpPost]
    public async Task Save(UserRequest user)
    {
        dbContext.Users.Add(new User { NickName = user.NickName });
        await dbContext.SaveChangesAsync();
    }
}









